package me.caofeng.pojo;

import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import me.caofeng.enums.ItemStatus;
import me.caofeng.serializer.JsonItemStatusSerializer;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.util.List;

/**
 * Copyright © 2017曹峰. All rights reserved.
 *
 * @Prject: mall
 * @Package: me.caofeng.pojo
 * @Description:
 * @Author: 曹峰 blog.caofeng.me
 * @Date: 2017-06-20 20:22
 * @Version: V1.0
 */
public class Product extends Pojo {
    /**
     * 商品所在类别
     */
    @NotNull(message = "商品分类不能为空")
    private Integer categoryId;

    /**
     * 商品名字
     */
    @NotNull(message = "商品名字不能为空")
    @Size(min = 1,message = "商品名字最少要一个字符")
    private String name;

    @NotNull(message = "商品副标题不能为空")
    @Size(min = 2 ,message = "商品副标题最少要两个字符")
    private String subTitle;

    /**
     * 产品主图
     */
    @NotNull(message = "产品主图不能为空")
    @Size(min = 10,message = "主图名字最少要10位")
    private String mainImage;

    /**
     * 产品子图
     */
    @NotNull(message = "产品子图不能为空")
    @Size(min = 1,max = 9,message = "最少要一张子图片，最多不能超过9张")
    private List<String> subImages;

    /**
     * 产品详情,可以使用html
     */
    @NotNull(message = "产品详情不能为空")
    @Size(min = 1,message = "产品详情不能为空")
    private String detail;

    /**
     * 价格
     */
    @NotNull(message = "产品价格不能为空")
    private Integer price;

    /**
     * 库存
     */
    @NotNull(message = "产品库存不能为空")
    private Integer stock;

    /**
     * 商品状态
     */
    @JsonSerialize(using = JsonItemStatusSerializer.class)
    private ItemStatus status;

    public Product() {
    }

    public Integer getCategoryId() {
        return categoryId;
    }

    public void setCategoryId(Integer categoryId) {
        this.categoryId = categoryId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMainImage() {
        return mainImage;
    }

    public void setMainImage(String mainImage) {
        this.mainImage = mainImage;
    }

    public List<String> getSubImages() {
        return subImages;
    }

    public void setSubImages(List<String> subImages) {
        this.subImages = subImages;
    }

    public String getDetail() {
        return detail;
    }

    public void setDetail(String detail) {
        this.detail = detail;
    }

    public Integer getPrice() {
        return price;
    }

    public void setPrice(Integer price) {
        this.price = price;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    public ItemStatus getStatus() {
        return status;
    }

    public void setStatus(ItemStatus status) {
        this.status = status;
    }

    public String getSubTitle() {
        return subTitle;
    }

    public void setSubTitle(String subTitle) {
        this.subTitle = subTitle;
    }

    @Override
    public String toString() {
        return "Product{" +
                "categoryId=" + categoryId +
                ", id=" + id +
                ", name='" + name + '\'' +
                ", createTime=" + createTime +
                ", updateTime=" + updateTime +
                ", mainImage='" + mainImage + '\'' +
                ", isDelete=" + isDelete +
                ", subImages=" + subImages +
                ", detail='" + detail + '\'' +
                ", price=" + price +
                ", stock=" + stock +
                ", status=" + status +
                '}';
    }
}
